<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ include file="/pages/inc/taglibs.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>使用工具服务</title>
	<%@ include file="/pages/inc/header.jsp" %>
	<style>
	#ptstool{color:blue}
	</style>
</head>

<body>
<%@ include file="/pages/inc/common.jsp" %>
<%@ include file="/pages/inc/menu.jsp" %>

<div class="pts-main">
	<%@ include file="/pages/inc/nav_pm.jsp" %>
	<div class="pts-page-title"><span>工具服务使用详情</span></div>
	<div class="container-fluid">
		服务状态：<span id="service-status" style="color:green">运行中</span>
		<div class="ui-table ui-margin">
			<input id="show" type="button" onclick="showDaily()" value="查看日志">
			<input type="button" onclick="javascript:history.back()" value="返回工具服务首页">
		</div>
		<input id="serviceId" name="serviceId" type="hidden" value="<c:out value='${serviceId}'/>" />
		<input id="projectId" name="projectId" type="hidden" value="<c:out value='${projectId}'/>"/>
		<input id="codePackageId" name="codePackageId" type="hidden" value="<c:out value='${codePackageId}'/>" />
		<pre>
		<div id="serviceInfo">
		1、服务基本信息
		</div>
		<div id="servicePcakgeInfo">
		2、服务使用代码包信息
		</div>
		<div id="serviceDailyInfo">
		</div>
		</pre>
	</div>
</div>

<%@ include file="/pages/inc/footer.jsp" %>
<script type="text/javascript">
	function fmtServiceInfo(s,flag){
		var html="";
		if(flag==1){
			html += "<p>服务名称："+s.toolname;
		}else if(flag==2){
			html += "<p>包名称："+s.packagename;
			html += "<p>包版本："+s.packageversion;
			html += "<p>包大小："+s.packagesize;
			html += "<p>源码路径："+s.sources;
			html += "<p>Class文件路径："+s.binaries;
			html += "<p>语言："+s.language;
			html += "<p>包描述："+s.description;
		}else{
             for(var i =0 ;i<s.length;i++){
                  html +="操作:"+s[i].type;
                  html +="&nbsp&nbsp&nbsp";
                  html +="操作人:"+s[i].creator;
                  html +="&nbsp&nbsp&nbsp";
                  html +="时间:"+s[i].creatdate+"<br>";
                  html +=s[i].operation+"<br>";
                 }
			}
		return html;
	}
	function initServiceInfo() {
		var serviceId = $("#serviceId").val();
		//获取服务基本信息
		$.ajax({
			url: contextPath+"/sonarservices/showServiceInfo",
			type:"POST",
			data:{"serviceId":serviceId},
			cache:false,
			async:false,
			success: function(data, textStatus, jqXHR){
				if(data){
					$("#serviceInfo").html(fmtServiceInfo(data,1));
				}
			}
		});
	}
	function initServicePcakgeInfo() {
		var codePackageId = $("#codePackageId").val();
		//获取服务使用代码包信息
		$.ajax({
			url: contextPath+"/sonarservices/showServicePackageInfo",
			type:"POST",
			data:{"codePackageId":codePackageId},
			cache:false,
			async:false,
			success: function(data, textStatus, jqXHR){
				if(data){
					$("#servicePcakgeInfo").html(fmtServiceInfo(data,2));
				}
			}
		});
	}
	function showDaily(){
		var serviceId = $("serviceId").val();
		var projectId = $("projectId").val();
		//获取服务使用代码包信息
		$.ajax({
			url: contextPath+"/sonarservices/showDaily",
			type:"POST",
			data:{"serviceId":serviceId,"projectId":projectId},
			cache:false,
			async:false,
			success: function(data, textStatus, jqXHR){
				$("#serviceDailyInfo").html(fmtServiceInfo(data,3));
				$("#serviceInfo").hide();
				$("#servicePcakgeInfo").hide();
			}
		});

		}
	//====================================================================
	//主方法
	$(function() {
		initServiceInfo();//初始化服务模块
		initServicePcakgeInfo();
	});
</script>
</body>
</html>
